/**
 * 
 */
package profile.report;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

/**
 * @author ductrung.tran
 *
 */
public class ParamCompareReport {

	public static class ParamResultReports {
		private List<ParamResultReport> reports = new ArrayList<ParamResultReport>();
		
		private long totalExecTime;
		private long totalCorbaTime;
		private long totalServerTime;
		private int count;
		
		public void add(ParamResultReport report) {
			reports.add(report);
			
			totalExecTime += report.getTotalExecTime();
			totalCorbaTime += report.getTotalCorbaTime();
			totalServerTime += report.getTotalServerTime();
			count += report.getCount();
		}
		
		public long getTotalExecTime() {
			return totalExecTime;
		}
		
		public long getTotalCorbaTime() {
			return totalCorbaTime;
		}
		
		public long getTotalServerTime() {
			return totalServerTime;
		}
		
		public int getCount() {
			return count;
		}
		
		public List<ParamResultReport> getReports() {
			return reports;
		}
	}
	
	private String param = "";
	private ParamResultReports firstReports = new ParamResultReports();
	private ParamResultReports secondReports = new ParamResultReports();
	
	public ParamCompareReport(String param,
			ParamResultReport firstReport,
			ParamResultReport secondReport) {
		this.param = param;
		addFirstReport(firstReport);
		addSecondReport(secondReport);
	}

	private void addSecondReport(ParamResultReport secondReport) {
		secondReports.add(secondReport);
	}

	private void addFirstReport(ParamResultReport firstReport) {
		firstReports.add(firstReport);
	}

	public ParamCompareReport(Collection<ParamResultReport> first,
			Collection<ParamResultReport> second) {
		for (ParamResultReport firstReport : first) {
			addFirstReport(firstReport);
		}
		for (ParamResultReport secondReport : second) {
			addSecondReport(secondReport);
		}
	}
	
	public String getParam() {
		return param;
	}
	public ParamResultReports getFirstReports() {
		return firstReports;
	}
	
	public ParamResultReports getSecondReports() {
		return secondReports;
	}

	public boolean isComparable() {
		return !param.equals("");
	}
}
